package com.ssaurel.mysleepquality.sleeptracker

import android.app.Application
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.ssaurel.mysleepquality.database.SleepDatabaseDao
import java.lang.IllegalArgumentException

/**
 * @ProjectName : MySleepQuality
 * @Author : 作者
 * @Time : 2021/10/11 10:42
 * @Description : 文件描述
 */
class SleepTrackerViewModelFactory(
    private val dataSource:SleepDatabaseDao,
    private val application: Application) : ViewModelProvider.Factory{
    override fun <T : ViewModel?> create(modelClass: Class<T>):T
    {
        if (modelClass.isAssignableFrom(SleepTrackerViewModel::class.java)){
            return SleepTrackerViewModel(dataSource,application) as T
        }
        throw IllegalArgumentException("Unknow ViewModel class")
    }

}